﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using Eniux.Windows.ThreeDEngine.Helper;

namespace Eniux.Windows.ThreeDEngine.ExtensionMethods
{
    public class ImageMaterialExtension : MarkupExtension
    {
        #region 变量

        /// <summary>
        /// 路径
        /// </summary>
        private readonly string path;

        #endregion

        #region 构造、析构

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="path"></param>
        public ImageMaterialExtension(string path)
        {
            this.path = path;
            this.Opacity = 1;
        }

        #endregion

        #region 公共属性

        /// <summary>
        /// 获取或设置透明度
        /// </summary>
        public double Opacity { get; set; }

        #endregion

        #region Public Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <returns></returns>
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return MaterialHelper.CreateImageMaterial(this.path, this.Opacity);
        }

        #endregion
    }
}
